package com.aboo.service.impl;

import java.util.List;

import com.aboo.dao.FrameConstantDao;
import com.aboo.po.FrameConstantPO;
import com.aboo.po.Page;
import com.aboo.pub.exception.BasicException;
import com.aboo.pub.result.ResultConstant;
import com.aboo.pub.result.ResultInfo;
import com.aboo.service.FrameConstantService;

public class FrameConstantServiceImpl implements FrameConstantService {
	
	private FrameConstantDao frameConstantDao;

	public void saveFrameConstant(ResultInfo ri, FrameConstantPO param)
			throws BasicException {
		try {
			frameConstantDao.save(param);
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("保存常量信息时出错", ex);
		}
	}

	public void deleteFrameConstant(ResultInfo ri, Integer constantId)
			throws BasicException {
		try {
			frameConstantDao.delete(constantId);
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("删除常量信息时出错", ex);
		}
	}

	public void updateFrameConstant(ResultInfo ri, FrameConstantPO param)
			throws BasicException {
		try {
			frameConstantDao.update(param);
			ri.setResultCode(ResultConstant.STATUS_OK);
		} catch (Exception ex) {
			throw new BasicException("保存常量信息时出错", ex);
		}
	}

	public void findFrameConstantList(ResultInfo ri, FrameConstantPO param,
			Page page) throws BasicException {
		try {
			if (page != null) {
				Integer count = frameConstantDao.findCount(param);
				page.setTotalRecordSize(count);
			}
			
			List<FrameConstantPO> result = frameConstantDao.findList(param, page);
			ri.setResultCode(ResultConstant.STATUS_OK);
			ri.setObj(result);
		} catch (Exception ex) {
			throw new BasicException("查询常量列表信息时出错", ex);
		}
	}
	
	public void findFrameConstant(ResultInfo ri, FrameConstantPO param) throws BasicException {
		try {
			FrameConstantPO result = frameConstantDao.find(param);
			ri.setResultCode(ResultConstant.STATUS_OK);
			ri.setObj(result);
		} catch (Exception ex) {
			throw new BasicException("查询常量信息时出错", ex);
		}
	}

	public FrameConstantDao getFrameConstantDao() {
		return frameConstantDao;
	}
	public void setFrameConstantDao(FrameConstantDao frameConstantDao) {
		this.frameConstantDao = frameConstantDao;
	}

}
